//
//  WorkBenchViewController.m
//  DaMaoMall
//
//  Created by HXHL-wally on 16/7/8.
//  Copyright © 2016年 daMao-wally. All rights reserved.
//

#import "WorkBenchViewController.h"
#import "MenuButtonView.h"
#import "WorkBenchTableViewCell.h"
#import "MyBusinessViewController.h"
#import "EnterpriseDisplayViewController.h"
#import "TransactionManagViewController.h"
#import "FinancialManagViewController.h"
#import "WorkBenchViewModel.h"

@interface WorkBenchViewController ()<UITableViewDelegate,UITableViewDataSource,MenuButtonViewDelegate>

@property (nonatomic, strong) UITableView * workBenchTableView;
@property (nonatomic, strong) WorkBenchViewModel * viewModel;

@end

@implementation WorkBenchViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.leftBtn.hidden = YES;
    self.titleLabel.text = @"北京大猫网络科技";
    
    @weakify(self);
//    RAC(self.viewModel,keywords)
    
    [self setUpTableView];
//    [self.navigationController.tabBarItem setBadgeValue:@""];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)setUpTableView{
    
    UITableView * workBenchTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, GetScreenWidth, GetScreenHeight-113) style:UITableViewStyleGrouped];
    self.workBenchTableView = workBenchTableView;
    self.workBenchTableView.delegate = self;
    self.workBenchTableView.dataSource = self;
    self.workBenchTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.contentView addSubview:self.workBenchTableView];
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        return 40.0f;
    }
    return 60.0f;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{

    CGFloat adViewH = GetScreenHeight * 0.24;
    

    return adViewH;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.01f;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView * headerView = [[UIView alloc]init];
    headerView.backgroundColor = [UIColor clearColor];
    
    NSArray * imageArray = @[@"findhome_0.png",@"findhome_1.png",@"findhome_2.png"];
    
    NSArray * menuLabelArray = @[@"我的商圈",@"交易管理",@"财务管理"];
    MenuButtonView * view = [MenuButtonView MenuButtonViewWithFarme:CGRectMake(0, 0, GetScreenWidth, GetScreenHeight*0.225) delegate:self ImageURLStringsGroup:imageArray titlesGroup:menuLabelArray];
    view.menuButtonViewDelegate = self;
    
    [headerView addSubview:view];
    return headerView;
}
#pragma mark - menuButtonView 代理
- (void)didSelectButtonAtIndex:(NSInteger)index{
    DMLog(@"%ld",(long)index);
    if (index == 2000) {
//        MyBusinessViewController * myBusinessVC = [[MyBusinessViewController alloc]init];
        EnterpriseDisplayViewController * enterprise = [[EnterpriseDisplayViewController alloc]init];
        [self.navigationController pushViewController:enterprise animated:YES];
    }
    if (index == 2001) {
        TransactionManagViewController * transactionManag = [[TransactionManagViewController alloc]init];
        [self.navigationController pushViewController:transactionManag animated:YES];
    }
    if (index == 2002) {
        FinancialManagViewController * financialManag = [[FinancialManagViewController alloc]init];
        [self.navigationController pushViewController:financialManag animated:YES];
    }
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 8;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString * cellStr = @"workBench";
    WorkBenchTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellStr];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle]loadNibNamed:@"WorkBenchTableViewCell" owner:nil options:nil]lastObject];
        if (indexPath.row == 0) {
            cell.textLabel.text = @"  我的待办";
            cell.textLabel.font = [UIFont systemFontOfSize:14];
            cell.iConBTN.hidden = YES;
            cell.statusLB.hidden = YES;
            cell.dateLB.hidden = YES;
            cell.acceptingBTN.hidden = YES;
            cell.cancelBTN.hidden = YES;
        }else{
           cell = [[[NSBundle mainBundle]loadNibNamed:@"WorkBenchTableViewCell" owner:nil options:nil]lastObject];
        }
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

@end
